﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace com.hyrentals.data
{
    public class User
    {
        public UserBasic Basic { get; set; }

        public UserDetail Detail { get; set; }
    }

    public class UserBasic
    {
        public string UserId { get; set; }

        public string Password { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public GenderTypeEnum GenderType { get; set; }

        public string Email { get; set; }

        public EmailStatusEnum EmailStatus { get; set; }

        public string PhoneNumber { get; set; }

        public PhoneStatusEnum? PhoneStatus { get; set; }

        public AccountStatusEnum AccountStatus { get; set; }

        public string Name
        {
            get
            {
                return string.Format("{0} {1}", FirstName, LastName);
            }
        }

    }

    public class UserDetail
    {
        public string UserId { get; set; }

        public string PasswordResetGuid { get; set; }

        public DateTime? PasswordResetGuidExpireDate { get; set; }

        public DateTime RegistrationDate { get; set; }

        public int ResidenceId { get; set; }

        public DateTime? BirthDate { get; set; }
    }

    public enum GenderTypeEnum : int
    {
        Unknown = 0,
        Male = 1,
        Female = 2,
    }

    public enum AccountStatusEnum : int
    {
        Disable = 0,
        Normal = 1,
    }

    public enum EmailStatusEnum : int
    {
        Unverified = 0,
        Verified = 1,
    }

    public enum PhoneStatusEnum : int
    {
        Unverified = 0,
        Verified = 1,
    }

    public enum UserTypeEnum : int
    {
        MinValue = 0,

        Unknown = MinValue,
        Consumer = 1,           //普通用户
        System = 5,             //系统用户

       
        // 增加新值时不能改变现有值, 必须更新MaxValue, 新增值不能与现有值相同(MaxValue例外)
        MaxValue = System
    }

    public static class UserTypeHelper
    {
        public static UserTypeEnum Parse(int v)
        {
            if (v < (int)UserTypeEnum.MinValue ||
                v > (int)UserTypeEnum.MaxValue)
            {
                return UserTypeEnum.Unknown; // throw new Exception??
            }

            return (UserTypeEnum)v;
        }
    }
}
